﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using csplCalculatorLib.Interface;
using csplCalculatorLib.Model;

namespace csplCalculatorLib
{
    public class MainCalculator
    {
        #region PrivateFields
        private IBasicCalculator _calculator;
        private CalModel _data;
        #endregion

        #region Constructors
        public MainCalculator()
        {
            this._calculator = new BasicCalculator();
        }
        #endregion

        #region Properties
        public CalModel Data
        {
            get { return _data; }
            set { _data = value; }
        }
        #endregion

        #region Methods
        public int Calculate()
        {
            int result = 0;
            if (this.Data != null)
            {
                if(this.Data.Mode == CalMode.Single)
                {
                    switch (this.Data.operation)
                    {
                        case CalOperations.Add :
                            if (this.Data.Mode == CalMode.Single)
                            {
                                result = this._calculator.Add(this.Data.integervalue1,
                                    this.Data.integervalue2);
                            }
                            else 
                            {
                                result = this._calculator.ComplexListOperation(this.Data.listDataOfInteger, this.Data.operation);
                            }
                            break;
                        case CalOperations.Sub:
                            result = this._calculator.Sub(this.Data.integervalue1,
                                this.Data.integervalue2);
                            break;
                        case CalOperations.Mul:
                            result = this._calculator.Mul(this.Data.integervalue1,
                                this.Data.integervalue2);
                            break;
                        case CalOperations.Div:
                            result = this._calculator.Div(this.Data.integervalue1,
                                this.Data.integervalue2);
                            break;
                        //case CalOperations.addList:
                        //    result = this._calculator.addList(this.Data.listDataOfInteger);
                        //    break;
                    }
                }
                else
                {
                
                }
                
            }
            else 
            {
                Console.WriteLine("There is no data to be calculate!");
            }
            return result;
        }
        #endregion      
    }

    public enum CalOperations { Add, Mul, Div, Sub}
    public enum CalMode { Single, List}
}
